﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FileDistribution.appcode
{
    public class Logs
    {
        static string path;
        static Logs()
        {
            path = Application.StartupPath + "/logs/" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
            string fpath=Path.GetDirectoryName(path);
            if (!Directory.Exists(fpath))
            {
                Directory.CreateDirectory(fpath);
            }
        }
        public static void Write(string msg)
        {
            using (var ws=File.AppendText(path))
            {
                ws.WriteLine("{0} 记录消息:{1}", DateTime.Now.ToString("HH:mm:ss"), msg);
            }
        }

        public static void Line()
        {
            using (var ws = File.AppendText(path))
            {
                ws.WriteLine("**************************分割线**************************");
            }
        }

        public static void Line(string header)
        {
            using (var ws = File.AppendText(path))
            {
                ws.WriteLine("=============================" + header + "==============================");
            }
        }
    }
}
